﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using pay.BLL;
using pay.Entity;
public partial class Buy : System.Web.UI.Page
{
    public string m_productname = "";//产品名称
    public string m_price = "";//原价
    public string m_nowprice = "";//现价
    public string lines1 = "";
    public string lines2 = "";
    public string m_productid = "";//产品编号
    public string strChk = "";
    public string strChk2 = "";

    protected void Page_Load(object sender, EventArgs e)
    {
      
        if (!IsPostBack)
        {
            var pid = Request["productid"]; //产品编号
            //var pid ="1";
            if (pid != null)
            {
                ProductInfo(int.Parse(pid));
            }
           
        }
    }

    ProductBLL bll = new ProductBLL();
    Product product = new Product();
    public void ProductInfo(int productid)
    {  
        //productid = 0;
        // var pid = Request["productid"]; //产品编号
        //var pid = "33";
        //int productid = 0;

        try
        {

            this.usertype.Style.Add("display", "none");
            this.usercheck.Style.Add("display", "none");
           // productid = int.Parse(pid);

            //if (productid == 34)
            //    strChk2 = "checked=\"checked\"";
            //else
            //    strChk = "checked=\"checked\"";


            product = bll.GetElementById(productid); //根据产品编号取得产品信息
            m_productid = productid + "";
            if (product != null)
            {
                m_productname = TempProductname(productid);
                if (product.Price - product.Nowprice == 0)
                {
                    m_price = "";

                }
                else
                {
                    m_price = "￥" + product.Price + "";
                }
                m_nowprice = product.Nowprice + "";

                //m_productid = productid;
                if (productid == 31 || productid == 33 || productid == 34 || productid == 35)
                {
                    lines1 = "<li class=\"dg_line\"></li>";
                    this.usertype.Style.Add("display", "block");
                    if (productid == 34)
                    {
                        lines2 = "<li class=\"dg_line\"></li>";
                        this.usercheck.Style.Add("display", "block");
                    }
                    else
                    {
                        this.usercheck.Style.Add("display", "none");
                    }
                }


            }
        }
        catch
        {
            productid = 0;
        }
    
    }
    public string TempProductname(int productid) //设置产品大类名称
    {
        /*31-new(1年),33,34-old(),35 手机主力版*/
        /*36 益盟超盘手乾坤版软件(一年版)*/
        string tmpmsg = "";
        if (productid == 31 || productid == 33 || productid == 34 || productid == 35)
        {
            tmpmsg = "手机操盘手主力版";
        }
        switch (productid)
        {
            case 36:
                tmpmsg = "操盘手乾坤版";
                break;
            case 1:
                tmpmsg = "操盘手决策版";
                break;
            case 32:
                tmpmsg = "操盘手主力版";
                break;
            case 45:
                tmpmsg = "手机操盘手决策版";
                break;
            case 43:
                tmpmsg = "操盘手盯盘先锋";
                break;
            case 17:
                tmpmsg = "操盘手加密狗";
                break;

        }
        return tmpmsg;
    }

    protected void newuser_CheckedChanged(object sender, EventArgs e)
    {
        //m_productname = TempProductname(31); //新用户
        ProductInfo(31);

    }
    protected void olduser_CheckedChanged(object sender, EventArgs e)
    {
        //m_productname = TempProductname(34); //老用户(手机主力版1年版)
        ProductInfo(34);
    }
}